
var webUrlCon = 'https://saas.51cjgc.com/api/';
//var webUrlCon = 'http://mesapitest.51cjgc.com/api';
//var webUrlCon = 'http://192.168.31.237:8080/api';
//var ossUrl = 'http://saas-pro.oss-cn-shenzhen.aliyuncs.com/';

/*var appToken='4384ff164fc75348ac0845d0604b7687';
var appUserId='1247';*/
var appToken=localStorage.appToken;
var appUserId=localStorage.appUserId;
//var webUrlCon = 'https://saas.51cjgc.com/api';
function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}

var u = navigator.userAgent;
if (u.indexOf('iPhone') > -1) {   //苹果手机
    $('body').addClass('mobile2');
    setupWebViewJavascriptBridge(function(bridge) {
        bridge.registerHandler('testJSFunction', function(data, responseCallback) {
            //alert('JS方法被调用:'+data);
            responseCallback('js执行过了');
        })
    });
}

/**window.onerror = function (errorMessage, scriptURI, lineNumber, columnNumber, errorObj) {
    var info = "错误信息：" + errorMessage + "</br>" +
        "出错文件：" + scriptURI + "</br> " +
        "出错行号：" + lineNumber + "</br>" +
        "出错列号：" + columnNumber + "</br>" +
        "错误详情：" + errorObj + "</br></br>";
    layer.open({
        content: info
        ,btn: '确定'
    });
}
**/

/* 时间转换 */
function formatDateTime(inputTime) {
    var date = new Date(inputTime);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    //return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    return y + '-' + m + '-' + d+' '+h+':'+minute;
};

/*移动端返回事件处理*/
function judgeOnBack() {
    return 2; //2回到上一页
}

/* 签名过期，退到登录 */
function  exit() {
    if (u.indexOf('iPhone') > -1) {   //苹果手机
        WebViewJavascriptBridge.callHandler('exit', {'conunt': ''}, function(response) {

        })
    }else {
        jsObj.exit();
    }
}
/* 图片上传和回显*/
//移动端调用（图片）
function transferPicture(str) {
    var strArr=JSON.parse(str);
    //alert('src='+strArr.length);

    var imgBase='';
    for(var i=0;i<strArr.length;i++){
       // alert(ossUrl+strArr[i])
        imgBase+='<div class="img">' +
       '<i class="fileDel  iconfont icon-shanchutupianqian"></i>' +
       '<img data-url="'+strArr[i]+'" src="'+ossUrl+strArr[i]+'">' +
       '</div>';
   }
   //alert(imgBase);
   $('.testImagesFile').before(imgBase)
   if($('#testImages .img').length>3){
       $('.testImagesFile').hide();
   }else{
       $('.testImagesFile').show();
   }
}
//（图片上传）
function chosenPicture() {
    layer.open({type: 2,shadeClose: false,});
    var leng=0;
    $("#testImages .img").each(function(index){
        leng++;
    });
    leng=4-leng;
    leng=leng.toString();
    //alert(leng);
    if (u.indexOf('iPhone') > -1) {   //苹果手机
        WebViewJavascriptBridge.callHandler('chosenPicture', {'conunt': leng}, function(response) {

        })
    }else {
        jsObj.chosenPicture(leng);
    }
    setTimeout(function () {
        layer.closeAll();
    },1000)
}